#include <plot.h>


void plotFlowVector(int imcount, char *filename, vector<Point2f> flowPoint, vector<Point2f> flowScale)
{
  char dirname[128];
  sprintf(dirname,"data/plotdata/%s_%05d.dat",filename, imcount);
  FILE *fp = fopen(dirname, "w");
  for(uint i = 0 ; i < flowPoint.size() ; i++)
    {
      fprintf(fp, "%f %f %f %f\n", flowPoint[i].x, flowPoint[i].y, flowScale[i].x, flowScale[i].y);

    }
  fclose(fp);
}

void plotFlowP2d(int imcount, char *filename, vector< pair< P2d, P2d> > flow)
{
  char dirname[128];
  sprintf(dirname,"data/plotdata/%s_%05d.dat",filename, imcount);
  FILE *fp = fopen(dirname, "w");
  for(uint i = 0 ; i < flow.size() ; i++)
    {
      fprintf(fp, "%f %f %f %f\n", flow[i].first.first, flow[i].first.second, flow[i].second.first, flow[i].second.second);

    }
  fclose(fp);
}

void plotFlow(int imcount, char *filename, vector<Point2f> flowPoint, vector<Point2f> flowScale, int VorP = 0)
{
  if(VorP == 0)
    plotFlowVector(imcount, filename, flowPoint, flowScale);

  else
    {
      vector< pair<P2d, P2d> > vals;
      convertflowPoint2P2d(flowPoint, flowScale, &vals);
      plotFlowP2d(imcount, filename, vals);
    }
}
